/**
 * nullFunction:定一个空的函数
 * eeesysCallSure:用于确定时回调执行的程序的对象,可以不需要
 * todo:  alert可以有两个参数（内容和标题），也可以是一个参数，默认标题为通知
 */
var nullFunction = function() {}
//loading加载
var eeesysLoading = function (data) {
	var data = data || {};
    var content = data.content || "请等待";
		var bodyFram = document.createElement( "DIV" );
				bodyFram.id = "eeesysLoading";
    var loadingFram = document.createElement( "DIV" );
        loadingFram.id = "eeesysLoadingBody";
    var strHtml = '<div id="eeesys-loading-orange" class="eeesys-loading-box"></div>' +
									'<div id="eeesys-loading-green" class="eeesys-loading-box"></div>' +
									'<div id="eeesys-loading-yellow" class="eeesys-loading-box"></div>';
    loadingFram.innerHTML = strHtml;
		bodyFram.appendChild(loadingFram);
	var body = document.body;
	if (data.el) {
		body = document.querySelector(data.el);
	}
    body.appendChild( bodyFram );
}
//loading停止
var eeesysLoadingCancel = function (data) {
	var data = data || {};
  var loadingFram = document.getElementById("eeesysLoading");
	var body = document.body;
	if (data.el) {
		body = document.querySelector(data.el);
	}
	loadingFram && loadingFram.parentNode.removeChild( loadingFram )
}
var eeesysPlugin = eeesysPlugin || {};
eeesysPlugin.menu = function(data) {
	var body = document.querySelector("body");
	this.eeesysPluginCancel = function() {
		body.removeChild(rootDom);
		event.stopPropagation();
	}
	var menus = data.menus || [];
	var rootDom = document.createElement("div");
	rootDom.className = "eeesysPlugin-menu-big";
	var parentDom = document.createElement("div");
	rootDom.appendChild(parentDom);
	parentDom.className = "eeesysPlugin-menu-half animated fadeInUpBig";
	rootDom.addEventListener("click", this.eeesysPluginCancel);
	if (data.tip) {
		var tipDom = document.createElement("div");
		parentDom.appendChild(tipDom);
		tipDom.className = "eeesysPlugin-menu-tip";
		tipDom.innerHTML = '<p>' + data.tip + '</p>';
	}

	menus.forEach(function(item) {
		var dom = document.createElement("div");
		dom.className = "eeesysPlugin-menu-item";
		dom.innerHTML = "<p>" + item.txt + "</p>";
		dom.addEventListener("click", this.eeesysPluginCancel);
		dom.addEventListener("click", item.func);
		parentDom.appendChild(dom);
	}.bind(this));
	var cancelDom = document.createElement("div");
	parentDom.appendChild(cancelDom);
	cancelDom.className = "eeesysPlugin-menu-last";
	cancelDom.addEventListener("click", this.eeesysPluginCancel);
	cancelDom.innerHTML = '<p>取消</p>';
	body.appendChild(rootDom);
}
eeesysPlugin.ok = function(data) {
	var body = document.querySelector("body");
	var rootDom = document.createElement("div");
	rootDom.className = "eeesysplugin-finished-box";
	var html = '<div class="eeesysplugin-finished-yes">' +
					'<img src="/style/eeesysPlugin/v2/ok.png" alt="已完成" />' +
					'<p>' + (data.txt || "操作成功") + '</p>' +
				'</div>';
	rootDom.innerHTML = html;
	body.appendChild(rootDom);
	setTimeout(function() {
		body.removeChild(rootDom);
	}, 1000);
}
